﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace RelationExpertSystem.Relation
{
    public class Sibling_In_Law : RelationBase
    {
        private static Sibling_In_Law _singleton = new Sibling_In_Law();
        public static Sibling_In_Law Instance
        {
            get { return _singleton; }
        }

        private Sibling_In_Law() { }

        public override bool IsRelated(Person a, Person b)
        {
            // b is a's Sibling_In_Law IFF b is a sibling of a's spouse OR a is a sibling of b's spouse
            // ignore in-law via ex_spouse for now
            return (!Person.IsNull(a.Spouse) && a.Spouse.KnownRelation(Sibling.Instance, b)) ||
                   (!Person.IsNull(b.Spouse) && b.Spouse.KnownRelation(Sibling.Instance, a));
        }

        public override IEnumerable<IRelation> GetDependencies()
        {
            return new HashSet<IRelation>(new IRelation[] { Spouse.Instance, Sibling.Instance });
        }
    }
}
